#include "widget.h"
#include "ui_widget.h"
#include <QDebug>
#include <QEvent>
#include <QMouseEvent>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
}

Widget::~Widget()
{
    delete ui;
}

bool Widget::event(QEvent *ev)
{
    if (ev->type() == QEvent::MouseButtonPress)
    {
          qDebug() << "鼠标左键拦截";
          return true;
    }

    // 其他事件交给父类
    return QWidget::event(ev);
}

void Widget::mousePressEvent(QMouseEvent *event)
{
    if (event->button() == Qt::LeftButton)
    {
        qDebug() << "鼠标左键按下";
    }
}

